package test;

public class Demo {
    public static void main(String[] args) {
        String ss = "0939";
        System.out.println(Integer.parseInt(ss));

//        System.out.println(position(new int[]{1,2,3,5}, 0));
//        System.out.println(position(new int[]{1,2,3,5}, 1));
//        System.out.println(position(new int[]{1,2,3,5}, 2));
//        System.out.println(position(new int[]{1,2,3,5}, 3));
//        System.out.println(position(new int[]{1,2,3,5}, 4));
//        System.out.println(position(new int[]{1,2,3,5}, 5));
//        System.out.println(position(new int[]{1,2,3,5}, 6));
    }

    static int position(int arr[], int target){

        for (int i = 0; i < arr.length; i++){

            if (arr[i] == target){
                return i;
            }

            if (arr[i] < target && (i + 1) < arr.length && arr[i+1] > target){
                return i + 1;
            }

            if (i == arr.length - 1){
                return i;
            }

            if (i == 0 && arr[i] > target){
                return i;
            }
        }

        return 0;
    }


}
